/*
 * Copyright (c) csii.com.cn 2016 zhaojin
 */

package com.csii.ssm.dto;

import org.apache.commons.collections.map.HashedMap;

import java.util.HashMap;
import java.util.Map;

/**
 * Ajax数据传输对象
 *
 * @author zhaojin 15398699939@163.com
 * @create 2016-08-12-22:17
 */

public class AjaxData {

    public enum AjaxDataField{
        status,msg,errmsg,errcode,dataMap;
    }

    private String status;//0000 成功/ 4444 失败
    private String msg;
    private String errmsg;
    private String errcode;
    private Map<String,Object> dataMap;

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public AjaxData setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public String getErrmsg() {
        return errmsg;
    }

    public void setErrmsg(String errmsg) {
        this.errmsg = errmsg;
    }

    public Map<String, Object> getDataMap() {
        return dataMap;
    }

    public AjaxData setDataMap(Map<String, Object> dataMap) {
        this.dataMap = dataMap;
        return this;
    }

    public String getErrcode() {
        return errcode;
    }

    public void setErrcode(String errcode) {
        this.errcode = errcode;
    }

    @Override
    public String toString() {
        return "AjaxData{" +
                "status='" + status + '\'' +
                ", msg='" + msg + '\'' +
                ", errmsg='" + errmsg + '\'' +
                ", errcode='" + errcode + '\'' +
                ", dataMap=" + dataMap +
                '}';
    }

    public AjaxData put(String key, Object val) {
        if(null==dataMap){
            dataMap = new HashMap();
        }
        dataMap.put(key,val);
        return this;
    }
}
